package base.io;





import java.io.*;

public class TestBufferStream2 {
    public static void main(String[] args) {
        try {
            BufferedWriter bw = new BufferedWriter(new FileWriter("d:\\dat2.txt"));
            BufferedReader br = new BufferedReader(new FileReader("d:\\dat2.txt"));
            String s = null;
            for(int i=1;i<=100;i++){
                s = String.valueOf(Math.random());
                bw.write(s);
                //文件里写一个换行符
                bw.newLine();
            }
            //把缓冲的数据写到文件
            bw.flush();
            while((s=br.readLine())!=null){
                System.out.println(s);
            }
            bw.close();
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
